package cn.itsource.user.controller;

import cn.itsource.basic.utli.AjaxResult;
import cn.itsource.user.domain.User;
import cn.itsource.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private IUserService userService;

    @PostMapping("/checkPhone")
    public AjaxResult checkPhone(@RequestBody Map<String,String> map){
        String phone = map.get("phone");
        User user = userService.checkPhone(phone);
        if(user!=null){//说明用户存在
            return AjaxResult.me().setMessage("用户已存在");
        }
        return AjaxResult.me();
    }
}
